package ru.myrtle.umf.impl;

import java.util.*;
import ru.myrtle.umf.*;
import ru.myrtle.umf.util.*;

public class UClassImpl extends UObjectImpl implements UClass {

    protected static final boolean PROVIDED_DEFAULT = Boolean.FALSE;
    protected static final boolean VIRTUAL_DEFAULT = Boolean.FALSE;
    protected static final String INSTANCE_CLASS_NAME_DEFAULT = null;
    protected static final String NAME_DEFAULT = null;
    protected static final String DESCRIPTION_DEFAULT = null;

    public UClassImpl() {
    }

    @Override
    public UClass uClass() {
        return UModel.UCLASS;
    }
    
    private boolean _provided_ = PROVIDED_DEFAULT;

    @Override
    public final boolean isProvided() {
        return _provided_;
    }

    @Override
    public final boolean isSetProvided() {
        return _provided_ != PROVIDED_DEFAULT;
    }

    @Override
    public final void setProvided(boolean _provided_) {
        this._provided_ = _provided_;
    }

    @Override
    public final void unsetProvided() {
        _provided_ = PROVIDED_DEFAULT;
    }

    private boolean _virtual_ = VIRTUAL_DEFAULT;

    @Override
    public final boolean isVirtual() {
        return _virtual_;
    }

    @Override
    public final boolean isSetVirtual() {
        return _virtual_ != VIRTUAL_DEFAULT;
    }

    @Override
    public final void setVirtual(boolean _virtual_) {
        this._virtual_ = _virtual_;
    }

    @Override
    public final void unsetVirtual() {
        _virtual_ = VIRTUAL_DEFAULT;
    }

    private UList<UClass> _superTypes_;

    @Override
    public final UList<UClass> getSuperTypes() {
        if (_superTypes_ == null) {
            _superTypes_ = new UObjectList<UClass>();
        }
        return _superTypes_;
    }

    @Override
    public final boolean isSetSuperTypes() {
        return _superTypes_ != null && !_superTypes_.isEmpty();
    }

    @Override
    public void setSuperTypes(UList<UClass> _superTypes_) {
        getSuperTypes().clear();
        getSuperTypes().addAll(_superTypes_);
    }

    @Override
    public void unsetSuperTypes() {
        if (_superTypes_ != null) {
            _superTypes_.clear();
        }
    }

    @Override
    public final UList<UClass> getAllSuperTypes() {
        return UClassOperations.INSTANCE.getAllSuperTypes(this);
    }

    @Override
    public final boolean isSetAllSuperTypes() {
        return UClassOperations.INSTANCE.isSetAllSuperTypes(this);
    }

    @Override
    public final UList<UAttribute> getIdentifyingAttributes() {
        return UClassOperations.INSTANCE.getIdentifyingAttributes(this);
    }

    @Override
    public final boolean isSetIdentifyingAttributes() {
        return UClassOperations.INSTANCE.isSetIdentifyingAttributes(this);
    }

    private UList<UFeature> _features_;

    @Override
    public final UList<UFeature> getFeatures() {
        if (_features_ == null) {
            _features_ = new UObjectContainmentWithInverseList<UFeature>(this, UModel.UCLASS__FEATURES, UModel.UFEATURE__CONTAINING_CLASS);
        }
        return _features_;
    }

    @Override
    public final boolean isSetFeatures() {
        return _features_ != null && !_features_.isEmpty();
    }

    @Override
    public void setFeatures(UList<UFeature> _features_) {
        getFeatures().clear();
        getFeatures().addAll(_features_);
    }

    @Override
    public void unsetFeatures() {
        if (_features_ != null) {
            _features_.clear();
        }
    }

    @Override
    public final UList<UFeature> getAllFeatures() {
        return UClassOperations.INSTANCE.getAllFeatures(this);
    }

    @Override
    public final boolean isSetAllFeatures() {
        return UClassOperations.INSTANCE.isSetAllFeatures(this);
    }

    @Override
    public final UList<UAttribute> getAttributes() {
        return UClassOperations.INSTANCE.getAttributes(this);
    }

    @Override
    public final boolean isSetAttributes() {
        return UClassOperations.INSTANCE.isSetAttributes(this);
    }

    @Override
    public final UList<UAttribute> getAllAttributes() {
        return UClassOperations.INSTANCE.getAllAttributes(this);
    }

    @Override
    public final boolean isSetAllAttributes() {
        return UClassOperations.INSTANCE.isSetAllAttributes(this);
    }

    @Override
    public final UList<UReference> getReferences() {
        return UClassOperations.INSTANCE.getReferences(this);
    }

    @Override
    public final boolean isSetReferences() {
        return UClassOperations.INSTANCE.isSetReferences(this);
    }

    @Override
    public final UList<UReference> getAllReferences() {
        return UClassOperations.INSTANCE.getAllReferences(this);
    }

    @Override
    public final boolean isSetAllReferences() {
        return UClassOperations.INSTANCE.isSetAllReferences(this);
    }

    @Override
    public final UList<UOperation> getAllOperations() {
        return UClassOperations.INSTANCE.getAllOperations(this);
    }

    @Override
    public final boolean isSetAllOperations() {
        return UClassOperations.INSTANCE.isSetAllOperations(this);
    }

    private UPackage _package_;

    @Override
    public final UPackage getPackage() {
        return _package_;
    }

    @Override
    public final boolean isSetPackage() {
        return _package_ != null;
    }

    private void setPackageImpl(UPackage _package_) {
        this._package_ = _package_;
    }

    private UList<UOperation> _operations_;

    @Override
    public final UList<UOperation> getOperations() {
        if (_operations_ == null) {
            _operations_ = new UObjectContainmentWithInverseList<UOperation>(this, UModel.UCLASSIFIER__OPERATIONS, UModel.UOPERATION__CONTAINING_CLASSIFIER);
        }
        return _operations_;
    }

    @Override
    public final boolean isSetOperations() {
        return _operations_ != null && !_operations_.isEmpty();
    }

    @Override
    public void setOperations(UList<UOperation> _operations_) {
        getOperations().clear();
        getOperations().addAll(_operations_);
    }

    @Override
    public void unsetOperations() {
        if (_operations_ != null) {
            _operations_.clear();
        }
    }

    private String _instanceClassName_ = INSTANCE_CLASS_NAME_DEFAULT;

    @Override
    public final String getInstanceClassName() {
        return _instanceClassName_;
    }

    @Override
    public final boolean isSetInstanceClassName() {
        return _instanceClassName_ != INSTANCE_CLASS_NAME_DEFAULT;
    }

    @Override
    public final void setInstanceClassName(String _instanceClassName_) {
        this._instanceClassName_ = _instanceClassName_;
    }

    @Override
    public final void unsetInstanceClassName() {
        _instanceClassName_ = INSTANCE_CLASS_NAME_DEFAULT;
    }

    @Override
    public final Class getInstanceClass() {
        return UClassOperations.INSTANCE.getInstanceClass(this);
    }

    @Override
    public final boolean isSetInstanceClass() {
        return UClassOperations.INSTANCE.isSetInstanceClass(this);
    }

    @Override
    public final void setInstanceClass(Class _instanceClass_) {
        UClassOperations.INSTANCE.setInstanceClass(this, _instanceClass_);
    }

    @Override
    public final void unsetInstanceClass() {
        UClassOperations.INSTANCE.unsetInstanceClass(this);
    }
    
    @Override
    public final String getInstanceTypeName() {
        return UClassOperations.INSTANCE.getInstanceTypeName(this);
    }

    @Override
    public final boolean isSetInstanceTypeName() {
        return UClassOperations.INSTANCE.isSetInstanceTypeName(this);
    }

    @Override
    public final void setInstanceTypeName(String _instanceTypeName_) {
        UClassOperations.INSTANCE.setInstanceTypeName(this, _instanceTypeName_);
    }

    @Override
    public final void unsetInstanceTypeName() {
        UClassOperations.INSTANCE.unsetInstanceTypeName(this);
    }
    
    @Override
    public final Object getDefaultValue() {
        return UClassOperations.INSTANCE.getDefaultValue(this);
    }

    @Override
    public final boolean isSetDefaultValue() {
        return UClassOperations.INSTANCE.isSetDefaultValue(this);
    }

    private String _name_ = NAME_DEFAULT;

    @Override
    public final String getName() {
        return _name_;
    }

    @Override
    public final boolean isSetName() {
        return _name_ != NAME_DEFAULT;
    }

    @Override
    public final void setName(String _name_) {
        this._name_ = _name_;
    }

    @Override
    public final void unsetName() {
        _name_ = NAME_DEFAULT;
    }

    private String _description_ = DESCRIPTION_DEFAULT;

    @Override
    public final String getDescription() {
        return _description_;
    }

    @Override
    public final boolean isSetDescription() {
        return _description_ != DESCRIPTION_DEFAULT;
    }

    @Override
    public final void setDescription(String _description_) {
        this._description_ = _description_;
    }

    @Override
    public final void unsetDescription() {
        _description_ = DESCRIPTION_DEFAULT;
    }

    private UList<UAnnotation> _annotations_;

    @Override
    public final UList<UAnnotation> getAnnotations() {
        if (_annotations_ == null) {
            _annotations_ = new UObjectContainmentList<UAnnotation>(this, UModel.UELEMENT__ANNOTATIONS);
        }
        return _annotations_;
    }

    @Override
    public final boolean isSetAnnotations() {
        return _annotations_ != null && !_annotations_.isEmpty();
    }

    @Override
    public void setAnnotations(UList<UAnnotation> _annotations_) {
        getAnnotations().clear();
        getAnnotations().addAll(_annotations_);
    }

    @Override
    public void unsetAnnotations() {
        if (_annotations_ != null) {
            _annotations_.clear();
        }
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public Object uGet(UFeature feature) {
        if (feature == UModel.UCLASS__PROVIDED) {
            return isProvided();
        }
        if (feature == UModel.UCLASS__VIRTUAL) {
            return isVirtual();
        }
        if (feature == UModel.UCLASS__SUPER_TYPES) {
            return getSuperTypes();
        }
        if (feature == UModel.UCLASS__ALL_SUPER_TYPES) {
            return getAllSuperTypes();
        }
        if (feature == UModel.UCLASS__IDENTIFYING_ATTRIBUTES) {
            return getIdentifyingAttributes();
        }
        if (feature == UModel.UCLASS__FEATURES) {
            return getFeatures();
        }
        if (feature == UModel.UCLASS__ALL_FEATURES) {
            return getAllFeatures();
        }
        if (feature == UModel.UCLASS__ATTRIBUTES) {
            return getAttributes();
        }
        if (feature == UModel.UCLASS__ALL_ATTRIBUTES) {
            return getAllAttributes();
        }
        if (feature == UModel.UCLASS__REFERENCES) {
            return getReferences();
        }
        if (feature == UModel.UCLASS__ALL_REFERENCES) {
            return getAllReferences();
        }
        if (feature == UModel.UCLASS__ALL_OPERATIONS) {
            return getAllOperations();
        }
        if (feature == UModel.UCLASSIFIER__PACKAGE) {
            return getPackage();
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            return getOperations();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            return getInstanceClassName();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            return getInstanceClass();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            return getInstanceTypeName();
        }
        if (feature == UModel.UCLASSIFIER__DEFAULT_VALUE) {
            return getDefaultValue();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return getName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return getDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return getAnnotations();
        }

        return super.uGet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public boolean uIsSet(UFeature feature) {
        if (feature == UModel.UCLASS__PROVIDED) {
            return isSetProvided();
        }
        if (feature == UModel.UCLASS__VIRTUAL) {
            return isSetVirtual();
        }
        if (feature == UModel.UCLASS__SUPER_TYPES) {
            return isSetSuperTypes();
        }
        if (feature == UModel.UCLASS__ALL_SUPER_TYPES) {
            return isSetAllSuperTypes();
        }
        if (feature == UModel.UCLASS__IDENTIFYING_ATTRIBUTES) {
            return isSetIdentifyingAttributes();
        }
        if (feature == UModel.UCLASS__FEATURES) {
            return isSetFeatures();
        }
        if (feature == UModel.UCLASS__ALL_FEATURES) {
            return isSetAllFeatures();
        }
        if (feature == UModel.UCLASS__ATTRIBUTES) {
            return isSetAttributes();
        }
        if (feature == UModel.UCLASS__ALL_ATTRIBUTES) {
            return isSetAllAttributes();
        }
        if (feature == UModel.UCLASS__REFERENCES) {
            return isSetReferences();
        }
        if (feature == UModel.UCLASS__ALL_REFERENCES) {
            return isSetAllReferences();
        }
        if (feature == UModel.UCLASS__ALL_OPERATIONS) {
            return isSetAllOperations();
        }
        if (feature == UModel.UCLASSIFIER__PACKAGE) {
            return isSetPackage();
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            return isSetOperations();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            return isSetInstanceClassName();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            return isSetInstanceClass();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            return isSetInstanceTypeName();
        }
        if (feature == UModel.UCLASSIFIER__DEFAULT_VALUE) {
            return isSetDefaultValue();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return isSetName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return isSetDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return isSetAnnotations();
        }

        return super.uIsSet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uSet(UFeature feature, Object value) {
        if (feature == UModel.UCLASS__PROVIDED) {
            setProvided(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UCLASS__VIRTUAL) {
            setVirtual(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UCLASS__SUPER_TYPES) {
            setSuperTypes((UList<UClass>) value);
            return;
        }
        if (feature == UModel.UCLASS__FEATURES) {
            setFeatures((UList<UFeature>) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            setOperations((UList<UOperation>) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            setInstanceClassName((String) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            setInstanceClass((Class) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            setInstanceTypeName((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            setName((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            setDescription((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            setAnnotations((UList<UAnnotation>) value);
            return;
        }

        super.uSet(feature, value);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uUnset(UFeature feature) {
        if (feature == UModel.UCLASS__PROVIDED) {
            unsetProvided();
            return;
        }
        if (feature == UModel.UCLASS__VIRTUAL) {
            unsetVirtual();
            return;
        }
        if (feature == UModel.UCLASS__SUPER_TYPES) {
            unsetSuperTypes();
            return;
        }
        if (feature == UModel.UCLASS__FEATURES) {
            unsetFeatures();
            return;
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            unsetOperations();
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            unsetInstanceClassName();
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            unsetInstanceClass();
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            unsetInstanceTypeName();
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            unsetName();
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            unsetDescription();
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            unsetAnnotations();
            return;
        }

        super.uUnset(feature);
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseAdd(UObject otherEnd, UReference reference) {
        if (reference == UModel.UCLASS__FEATURES) {
            ((UObjectList<UFeature>) getFeatures()).basicAdd((UFeature) otherEnd);
            return;
        }
        if (reference == UModel.UCLASSIFIER__PACKAGE) {
            setPackageImpl((UPackage) otherEnd);
            return;
        }
        if (reference == UModel.UCLASSIFIER__OPERATIONS) {
            ((UObjectList<UOperation>) getOperations()).basicAdd((UOperation) otherEnd);
            return;
        }
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseRemove(UObject otherEnd, UReference reference) {
        if (reference == UModel.UCLASS__FEATURES) {
            ((UObjectList<UFeature>) getFeatures()).basicRemove((UFeature) otherEnd);
            return;
        }
        if (reference == UModel.UCLASSIFIER__PACKAGE) {
            setPackageImpl(null);
            return;
        }
        if (reference == UModel.UCLASSIFIER__OPERATIONS) {
            ((UObjectList<UOperation>) getOperations()).basicRemove((UOperation) otherEnd);
            return;
        }
    }


    @Override
    public boolean isDirectSuperType(UClass someClass) {
        return UClassOperations.INSTANCE.isDirectSuperType(this, someClass);
    }

    @Override
    public boolean isSuperType(UClass someClass) {
        return UClassOperations.INSTANCE.isSuperType(this, someClass);
    }

    @Override
    public UObject createInstance() {
        return UClassOperations.INSTANCE.createInstance(this);
    }

    @Override
    public boolean isInstance(Object object) {
        return UClassOperations.INSTANCE.isInstance(this, object);
    }

    @Override
    public String toString() {
        StringBuffer result = new StringBuffer();

        result.append("UClass");
        result.append(" (");
        result.append("provided: ");
        result.append(_provided_);
        result.append(", ");
        result.append("virtual: ");
        result.append(_virtual_);
        result.append(", ");
        result.append("instanceClassName: ");
        result.append(_instanceClassName_);
        result.append(", ");
        result.append("name: ");
        result.append(_name_);
        result.append(", ");
        result.append("description: ");
        result.append(_description_);
        result.append(')');

        return result.toString();
    }
}




